package com.yowasa.xiuxian.engine.hone.mental;


import com.google.common.collect.Lists;
import com.yowasa.xiuxian.annoations.Mental;
import com.yowasa.xiuxian.engine.hone.MentalInterface;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.bo.user.UserBattle;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.entity.enums.StageEnum;
import com.yowasa.xiuxian.exception.HandlerException;

import java.util.List;

@Mental(name = "太玄经")
public class TaiXuanJing implements MentalInterface {


    @Override
    public ElementEnum getElement() {
        return null;
    }

    @Override
    public void limit(UserBO user) {
        if (user.getUserAttr().getUnd() > 30) {
            throw new HandlerException("修习太玄经悟性不能大于30");
        }
    }

    @Override
    public String limitDesc() {
        return "悟性不能大于30";
    }

    @Override
    public String desc() {
        return "无属性心法,特点是能全方面提高修习者的属性,修炼速度与悟性成反比";
    }

    @Override
    public List<String> bsList() {
        return Lists.newArrayList("玄妙剑");
    }

    @Override
    public String breakUp(UserBO user) {
        UserBattle upBattle = getBaseUp(user);
        upBattle.setHp((int) ((upBattle.getHp() + 20) * 1.3));
        upBattle.setChp(upBattle.getHp());
        upBattle.setMp((int) (upBattle.getMp() * 1.3));
        upBattle.setCmp(upBattle.getMp());
        upBattle.setAtk((int) ((upBattle.getAtk() + 5) * 1.3));
        upBattle.setSpell((int) ((upBattle.getSpell() + 5) * 1.3));
        upBattle.setSpd((int) (upBattle.getSpd() * 1.2));
        upBattle.setDef((int) (upBattle.getDef() * 1.3));
        upBattle.setRes((int) ((upBattle.getRes() + 5) * 1.3));
        upBattle.setImm((int) (upBattle.getImm() * 1.5));
        buildNewUpBattle(user, upBattle);
        return upBattle.getUpDesc();
    }

    @Override
    public List<String> specialList() {
        return Lists.newArrayList("太玄妙法");
    }

    //预估修炼时间
    public int getExpect(UserBO user) {
        Integer code = user.getStage();
        StageEnum level = StageEnum.getById(code);
        int need = level.getNeed();
        return ((100 - user.getLevel()) * need) * 200 / (30 * (120 - user.getUserAttr().getUnd()));
    }

    //修炼获取经验
    public int getExp(UserBO user, int days) {
        return 30 * (120 - user.getUserAttr().getUnd()) * days / 200;
    }

}
